
(function(){

var rules = {
  "Statement" : function(r) { with(r) {
    return node(alt(
      action(call("ExpressionStatement"), function(ctx) {
        ctx.nodeResult(this);
      }),
      action(call("VariableStatement"), function(ctx) {
        ctx.nodeResult(this);
      })
    ), {"nodeType" : "Statement"});
  }},
  "VariableStatement" : function(r) { with(r) {
    return node(seq(
      lit("var"),
      ws(),
      action(call("VariableDeclarationList"), function(ctx) {
        ctx.nodeResult(this);
      })
    ), {"nodeType" : "VariableStatement"});
  }},
  "VariableDeclarationList" : function(r) { with(r) {
    return node(alt(
      //call("VariableDeclaration"),
      seq(
        action(call("VariableDeclarationList"), function(ctx) {
          ctx.nodeResult(this);
        }),
        ows(),
        lit(","),
        ows(),
        call("VariableDeclaration")
      )
      ,call("VariableDeclaration")
    ), {"nodeType" : "VariableDeclarationList"});
  }},
  "VariableDeclaration" : function(r) { with(r) {
    return call("Identifier")
  }},
  "ExpressionStatement" : function(r) { with(r) {
    return call("PrimaryExpression")
  }}
};

for (var i in rules) {
  JavaScript.addRule(i, rules[i](JavaScript.combinators));
}

})();

